home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / HELP_MAN / HELP_EXA.C next >
C/C++ Source or Header  |  1990-04-18  |  1KB  |  76 lines

  1. /* this is a quick and dirty example of how to use my help manager
  2.  *
  3.  * It puts up a dialog that has a few topics for help
  4.  *
  5.  * I have the include MacHeaders option set
  6. */
  7.  
  8. #include "utilities.h"
  9. #include "help.h"
  10.  
  11. #define HELP_DLOG 128
  12. #define TOPIC_ITEM 3
  13. #define DATA_ITEM 4
  14. #define TOPIC_TYPE *(long*)"STR#"
  15. #define DATA_TYPE *(long*)"DATA"
  16. #define TOPIC_ID 128
  17. #define DATA_ID 128
  18. #define THE_FONT geneva
  19. #define THE_SIZE 12
  20.  
  21. static void DoIt(void);
  22.  
  23. void main(void)
  24. {
  25.  
  26.     InitToolbox();
  27.     
  28.     DoIt();
  29.  
  30. } /*main*/
  31.  
  32. static void DoIt(void)
  33. {
  34.  
  35.     DialogPtr    theDialog = GetNewDialog(HELP_DLOG,(void*)0,(void*)-1);
  36.     GrafPtr        TempPtr;
  37.     HelpHandle    help;
  38.     Rect        topicRect, dataRect;
  39.     short        itemHit = 0;
  40.     
  41.     CenterWindow(theDialog);
  42.     ShowWindow(theDialog);
  43.     
  44.     GetPort(&TempPtr);
  45.     SetPort(theDialog);
  46.     
  47.     TextFont(THE_FONT);
  48.     TextSize(THE_SIZE);
  49.     
  50.     topicRect = GetDItemBox(theDialog,TOPIC_ITEM);
  51.     dataRect = GetDItemBox(theDialog,DATA_ITEM);
  52.     
  53.     help = HelpNew(theDialog,topicRect,dataRect,TOPIC_TYPE,TOPIC_ID,DATA_TYPE,DATA_ID);
  54.     
  55.     FrameRect(&topicRect);
  56.     FrameRect(&dataRect);
  57.     
  58.     while (itemHit != OK && itemHit != Cancel) {
  59.         ModalDialog(GenericFilter,&itemHit);
  60.         
  61.         if (itemHit == TOPIC_ITEM || itemHit == DATA_ITEM) {
  62.             Point        where;
  63.             
  64.             GetMouse(&where);
  65.             HelpClick(help,where);
  66.         }
  67.     }
  68.     
  69.     SetPort(TempPtr);
  70.     
  71.     HelpDispose(help);
  72.     DisposDialog(theDialog);
  73.  
  74. } /*DoIt*/
  75.  
  76.